﻿using Microsoft.AspNetCore.Mvc;
using NET6.WebAPI.Entities.Base;
using NET6.WebAPI.Extensions;

namespace NET6.WebAPI.Controllers
{
    /// <summary>
    /// 用户管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UsersController : ControllerBase
    {
        private readonly ProjectDbContext _db;

        public UsersController(ProjectDbContext dbContext)
        {
            _db = dbContext;
        }

        /// <summary>
        /// 用户列表接口
        /// </summary>
        /// <param name="pages">第几页, 默认 1</param>
        /// <param name="pageRows">每页显示行数, 默认 15</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> List(int pages = 1, int pageRows = 15)
        {
            var pageData = await _db.Sys_User.GetPageDataAsync(pages, pageRows);
            return Ok(pageData);
        }
    }
}
